<template>

	<view class="content">
		<scroll-view class="category-first" :enable-flex="true" scroll-y :show-scrollbar="false"
			:scroll-top="scrollToTop" :scroll-with-animation="true">

			<view class="my-conts">
				<view class="name">选择日期/场次</view>
				<view class="" style="text-align: center;padding-left: 290rpx;padding-top: 30rpx" v-if="listLoading">
					<zy-load mode='fullCircle' style="margin: 0 auto;"></zy-load>
				</view>
				<view class="cs-time" v-else>
					<view class="my-item" v-for="(item, index) in newTimeList" :key="index">
						<view class="cs-item" :class="{'acIndex': item.index == timeAcIndex}"
							@click="timeAcIndex = index" v-if="index < 3">
							<view class="">
								{{ item.date }}
							</view>

						</view>
						<view class="cs-item cs-last-item" :class="{'acIndex': index == 4}" @click="showMoreTime"
							v-if="index == 3">
							更多<br>时间
						</view>
					</view>
				</view>
				<view class="name name1">选择优惠</view>
				<view class="quan-box">
					<view class="quan">
						<view class="left">抵用券/积分</view>
						<view class="right"><span @click="userCoupon">0张券可用</span>/{{ jifenData }}积分 <u-icon
								name="arrow-right" size="28"></u-icon> </view>
					</view>
					<!-- 对接口时候灵活改 -->
					<view class="quan" v-if=' couponMoney || jifenData'>
						<view class="left">抵用券/积分优惠</view>
						<view class="right unit">
							<zy-load mode='fullCircle' style="margin: 0 auto;" v-if="listLoading" size="6"></zy-load>
							<span v-else>
								<span class="font">积分</span>-￥{{userJF}}元
							</span>
						</view>
					</view>
				</view>
				<!-- <view class="name name1">选择积分</view>
				<view class="quan-box">
					<view class="quan">
						<view class="left">积分</view>
						<view class="right" @click="userJifen">{{ctPoints}}张券可用/共0张券 <u-icon name="arrow-right"
								size="28"></u-icon> </view>
				
						<view class="left">敬请期待</view>
					</view>
					<view class="quan" v-if='!!couponMoney'>
						<view class="left">抵用券优惠</view>
						<view class="right unit">-￥{{couponMoney}}</view>
					</view>
				</view> -->
				<view class="name name1">选择数量</view>
				<view class="number-box">
					<!-- 设置最大值 -->
					<u-number-box v-model="value" :max="timeList[timeAcIndex].remain" :min="1">
						<!-- <u-number-box v-model="value" :max="2" :min="1"> -->
						<view slot="minus" class="minus" >
							<u-icon name="minus" size="14"></u-icon>
						</view>
						<text slot="input" style="width: 50px;text-align: center;background-color: transparent;"
							class="input">{{value}} </text>
						<view slot="plus" class="plus">
							<u-icon name="plus" color="#FFFFFF" size="14"></u-icon>
						</view>
					</u-number-box>
				</view>
				<view class="name name1 name2"
					style="display: flex;flex-direction: row;justify-content: space-between;padding-bottom: 24rpx;">
					<view class="my-title" style="margin-top: -6rpx;">
						信息填写
						<view class="" style="position: relative;top: -24rpx;zoom: 0.8;">
							<view class="span"
								v-if="prodMsg.uubuyer_limit_content == 0 || prodMsg.uubuyer_limit_content == -1 || prodMsg.uubuyer_limit_content.buyer_order_total == 0 || prodMsg.uubuyer_limit_content.buyer_order_total == -1">
								<span v-if="perList.length == 1">已选满</span>
								<span v-else>需选 <span class="red" style="color:#FF3400">1</span> 位</span>
							</view>
							<view class="span" v-else-if="prodMsg.uubuyer_limit_content.buyer_order_total == 1">
								<span v-if="perList.length == value">已选满</span>
								<span v-else>{{perList.length > 0 ? '还' : ''}}需选 <span class="red"
										style="color:#FF3400">{{ value - perList.length}}</span> 位</span>
							</view>
						</view>
					</view>
					<view class="add-info" @click="addPerInfos">
						<image src="../../static/newImgs/add-icon.png" mode="" style="width: 32rpx;height: 32rpx;">
						</image>
						选择游客信息
					</view>
				</view>

				<view class="per-box">
					<view class="per-info-box" v-for="(item, index) in perList">
						<view class="names">
							<view class="label">姓名</view><span class="unt">*</span>
							<input v-model="item.ordername" type="text" class="myinput" placeholder="请输入您的姓名" />
						</view>
						<view class="phone">
							<view class="label">手机</view><span class="unt">*</span>
							<input v-model="item.ordertel" type="text" class="myinput" placeholder="请输入您的手机号" />
							<!-- <view class="phone-btn" open-type="getPhoneNumber" @getphonenumber="getPhone">获取手机号</view> -->
							<view type="primary" class="phone-btn my-phone-btn" size='medium' :data-index="index"
								:id="'u-btn' + index" v-if="wxPhone" @click="getPhone($event, index)">获取手机号
							</view>
							<u-button type="primary" class="phone-btn" size='medium' open-type="getPhoneNumber"
								:data-index="index" :id="'u-btn' + index" @getphonenumber="getPhone($event, index)"
								v-else>获取手机号
							</u-button>

						</view>
						<view class="idcardnumber">
							<view class="label">身份证</view><span class="unt">*</span>
							<input v-model="item.personid" type="text" class="myinput" placeholder="请输入您的身份证号" />
						</view>
						<view class="add-info delete-info" @click="deletePerInfo(index)" v-if="perList.length > 1">
							<image src="../../static/newImgs/delete-icon.png" mode=""
								style="width: 32rpx;height: 32rpx;"></image>
							删除人员信息
						</view>
					</view>

				</view>

			</view>
			<!-- <view class="add-info" @click="addPerInfo">
				<image src="../../static/newImgs/add-icon.png" mode="" style="width: 32rpx;height: 32rpx;"></image>
				添加人员信息
			</view> -->
		</scroll-view>
		<view class="pay-box">
			<view class="title">支付金额</view>
			<view class="money" style="display: flex;flex-direction: row;justify-content: center;">
				<!-- <span class="unit">¥</span>{{ timeList.length && parseFloat(timeList[timeAcIndex].retailPrice * value / 100).toFixed(2) }} -->

				<view class="unit">¥</view>
				<view>
					<zy-load mode='fullCircle' style="margin: 0 auto;" v-if="listLoading" size="12"></zy-load>
					<span v-else>{{ zfMoney }}</span>
				</view>
			</view>
			<!-- <view class="btm">支付</view> -->
			<view class="bottom">
				<view class="left">
					<image src="../../static/newImgs/tel.png" mode="aspectFit" class="img1"></image>
					<view class="">
						客服
					</view>
					<button open-type="contact" bindcontact="handleContact" class="customer-service">客服</button>
				</view>
				<!-- <view class="right" @click="orderMsg()">立即支付</view> -->
				<view class="right" @click="orderMsg()">立即支付</view>
			</view>
		</view>

		<u-popup v-model="timeAll" mode="bottom" border-radius="0">
			<view class="time-all">
				<view class="title">
					<view class="">
						请选择游玩日期
					</view>
					<view class="close" @click="timeAll = false">×</view>
				</view>
				<view class="sunday">
					<view>日</view>
					<view>一</view>
					<view>二</view>
					<view>三</view>
					<view>四</view>
					<view>五</view>
					<view>六</view>
				</view>
				<view v-for="(item, index) in monthList" :key="index">
					<view class="yue">
						{{monthList[index].substring(0, 4) + '年' + monthList[index].substring(5, 7) + '月' }}
					</view>
					<view class="day-box">
						<view class="my-day" v-for="(item2, index2) in timeList[0].hasDay" :key="index2"
							v-if="index == 0 " style="color:transparent">
							{{'11'}}
						</view>
						<view class="my-day"
							v-for="(item2, index2) in timeList[timeList.findIndex(i => i.isYC) ].hasDay" :key="index2"
							v-if="index == 1 " style="color:transparent">
							{{'11'}}
						</view>
						<view class="my-day"
							v-for="(item1, index1) in timeList.filter(i=> i.date.substring(5, 7) ==monthList[index].substring(5, 7) )"
							:key="index1 + 'aa'">
							<view class="day" @click="changeDate(item1.date)"
								:class="{'ac-day': timeAcIndex == item1.index}">
								<view class="">
									{{ item1.date.slice(-2) }}
								</view>
								<view class="money">{{ '¥' + parseFloat(item1.retailPrice / 100).toFixed(2) }}</view>
							</view>
						</view>

					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import zyLoad from '@/uni_modules/zy-loading/components/zy-loading/zy-loading.vue'
	export default {
		components: {
			zyLoad
		},
		data() {
			return {
				listLoading: false,
				moneyLoading: false,
				timeAll: false,
				scrollToTop: '',
				perList: [{
					ordername: '',
					ordertel: '',
					personid: '',
				}],
				value: 1,
				show: true,
				timeAcIndex: 0,
				couponMoney: '',
				newTimeList: [],
				timeList: [
					// '2024-01-01 19:30',
					// '2024-01-01 19:30',
					// '2024-01-01 19:30',
					// '2024-01-01 19:30',
					// '2024-01-01 19:30',
				],
				prodMsg: {},
				monthList: [],
				orderId: '',
				jifenData: 0,
				wxPhone: uni.getStorageSync('openId').phonenumber ? true : false
			}
		},
		computed: {
			allMoney() {
				if (this.timeList.length) {
					// console.log(parseFloat(this.timeList[this.timeAcIndex].retailPrice * this.value / 100).toFixed(2), this.value, this.timeList[this.timeAcIndex].retailPrice)
					return parseFloat(this.timeList[this.timeAcIndex].retailPrice * this.value / 100).toFixed(2);
				} else {
					return '--'
				}
			},
			userJF() {
				// console.log(this.allMoney, this.jifenData, this.allMoney < this.jifenData)
				return (parseFloat(this.allMoney) < parseFloat(this.jifenData)) ? this.allMoney : this.jifenData;
			},
			zfMoney() {
				return parseFloat(this.allMoney - this.userJF).toFixed(2)
			}
		},
		watch: {
			value: {
				handler(newVal, oldVal) {
					console.log(this.value, 'value变化了');
					if(this.perList.length > this.value) {
						this.perList.pop();
					}
				},
				deep: true // 深度监听  
			}
		},
		onShow() {

		},
		onLoad(params) {
			
			console.log(params, 11111, '上个页面带进来了什么参数')
			if (params.data) {
				this.prodMsg = JSON.parse(params.data);
				console.log(this.prodMsg)
				// this.prodMsg.uubuyer_limit_content = 0;
				this.prodMsg.uubuyer_limit_content = JSON.parse(this.prodMsg.uubuyerLimitContent);
				// this.prodMsg.uubuyer_limit_content.buyer_order_total
				console.log(this.prodMsg)
			}
			this.getMsg();
			this.getPointsList();
			this.getPerInfo();

		},
		methods: {
			// 获取默认游客信息
			getPerInfo() {
				let data = {
					customerId: uni.getStorageSync('openId').userId
				}
				this.$http({
					url: this.$myApi.sightList + '?userId=' + data.customerId + '&isSelf=' + 1,
					method: 'GET',
					hideLoading: true,
					data: {},
					success: res => {
						// console.log(res)
						if (res.rows.length > 0) {
							this.perList[0].id = res.rows[0].id;
							this.perList[0].ordername = res.rows[0].name;
							this.perList[0].ordertel = res.rows[0].mobilePhone;
							this.perList[0].personid = res.rows[0].idCardNo;
						}
					},
					complete: e => {
						uni.stopPullDownRefresh();
					}
				})
			},
			// 查看更多日期
			showMoreTime() {
				this.timeAll = true;
			},
			// 敬请期待
			jqqd() {
				uni.showToast({
					title: '敬请期待',
					duration: 2000,
					icon: 'none'
				});
			},

			getCurrentDate() {
				const today = new Date();
				const year = today.getFullYear();
				const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以需要+1  
				const date = String(today.getDate()).padStart(2, '0'); // 日期可能是1位数或2位数，所以需要.padStart()方法来补齐  

				return `${year}-${month}-${date}`;
			},
			getFutureDate7(days) {
				let timestamp = new Date().getTime()
				let one_day = 86400000; // 24 * 60 * 60 * 1000;
				let addVal = days * one_day + timestamp;
				//7天后的日期
				let date = new Date(addVal);
				//格式化日期
				let filters = n => {
					return n < 10 ? (n = '0' + n) : n;
				};
				let month = filters(date.getMonth() + 1);
				let day = filters(date.getDate());
				let lastTime = `${date.getFullYear()}-${month}-${day}`;
				return lastTime;
				// // console.log(lastTime,'时间');
			},
			// 判断某一天是不是月底的某一天
			isLastDayOfMonth(dateStr) {
				// 解析日期字符串为 Date 对象  
				const lastDate = dateStr.slice(-2);
				if (lastDate == '01') {
					return true;
				} else {
					return false;
				}
			},
			// 判断一天是星期几
			getDayOfWeek(dateStr) {
				const date = new Date(dateStr);
				const dayOfWeek = date.getDay();

				const days = [0, 1, 2, 3, 4, 5, 6];
				return days[dayOfWeek];
			},
			// 改变选中的日期
			changeDate(date) {

				this.timeAcIndex = this.timeList.findIndex(i => i.date == date);
				if (this.timeAcIndex > 2) {
					this.newTimeList = this.timeList.slice(this.timeAcIndex - 2, this.timeAcIndex + 1);
					this.newTimeList.push({})
					// console.log(this.newTimeList)
				} else {
					this.newTimeList = this.timeList.slice(0, 4)
				}
				this.timeAll = false;
			},
			// 获取积分
			getPointsList() {
				let data = {
					customerId: uni.getStorageSync('openId').userId
				}
				this.moneyLoading = true;
				this.$http({
					url: this.$myApi.pointsList + '?userId=' + data.customerId,
					method: 'GET',
					hideLoading: true,
					// data: data,
					success: res => {

						if (res.code == 200 && res.rows.length > 0) {
							this.jifenData = parseFloat(res.rows[0].ctPoints).toFixed(2); // 积分按元算
							// this.jifenData = 35.99;
						} else {}
					},
					fail: err => {

					},
					complete: e => {
						this.moneyLoading = false;
					}
				})
			},
			// 获取票务的信息
			getMsg() {
				let data = {
					aid: this.prodMsg.uuaid || '352929',
					pid: this.prodMsg.uupid || '970320',
					start_date: this.getCurrentDate(),
					end_date: this.getFutureDate7(14)
				}
				this.listLoading = true;
				// 票务接口
				this.$httpFormData.post(
						this.$myApi.getRealMsg,
						data, {
							header: {
								'Content-Type': 'application/x-www-form-urlencoded;charset=utf8',
								"Authorization": uni.getStorageSync('token') || 1,
								Clientid: uni.getStorageSync('clientID') || 1
							},
						}
					)
					.then(res => {
						if (res.code == 500) {
							uni.showToast({
								title: res.msg,
								duration: 2000,
								icon: 'none'
							});
							return;
						}
						this.monthList = [res.data.data[0].date];
						res.data.data.map((j, index) => {
							j.index = index;
							j.hasDay = this.getDayOfWeek(j.date)
							j.isYC = this.isLastDayOfMonth(j.date);
							if (j.isYC == true) {
								this.monthList.push(j.date)
							}
						})
						this.timeList = res.data.data;
						this.newTimeList = res.data.data.slice(0, 4);
						this.listLoading = false;
					})
					.catch(err => {
						this.listLoading = false;
						uni.showToast({
							title: err.msg,
							duration: 2000,
							icon: 'none'
						});
					})
			},
			// 微信支付
			// 发起微信支付
			pay() {
				this.loading = true
				this.$http({
					// #ifdef MP-WEIXIN
					url: this.$api.createOrders,
					// #endif
					// #ifdef APP-PLUS
					url: this.provider == 'wxpay' ? this.$api.wechatapp : this.$api.alipay,
					// #endif
					method: 'POST',
					hideLoading: false,
					data: {
						dianyingId: this.dyId,
						invitedCode: this.invitedCode,
						openid: this.openId,
						nickName: this.name,
						num: this.number,
						mobile: this.tel,
						type: 1,
						city: this.CinemaDetail.area[1],
						province: this.CinemaDetail.area[0],
					},
					success: res => {

						// #ifdef APP-PLUS
						if (this.provider == 'wxpay') {
							res = {
								timestamp: parseInt(res.timeStamp),
								package: res.package,
								appid: res.appid,
								sign: res.sign,
								partnerid: res.partnerId,
								prepayid: res.prepayId,
								noncestr: res.nonceStr
							}
						}
						// #endif
						// console.log('生成支付订单成功返回----------', res)
						this._pay(res)
					},
					fail: err => {
						// console.log('生成支付订单失败返回----------', err)
					},
					complete: e => {
						this.loading = false
						uni.hideLoading()
					}
				})


			},

			// 预付下单接口
			orderMsg() {
				let name = '';
				let ordertel = '';
				let personid = '';
				
				if (this.perList.length == 0) {
					uni.showToast({
						title: '请至少选择1位游客！',
						duration: 2000,
						icon: 'none'
					});
					return false;
				} else if (this.prodMsg.uubuyer_limit_content.buyer_order_total == 1 && this.value > this.perList.length) {
					uni.showToast({
						title: '请再选择' + (this.value - this.perList.length) + '位游客！',
						duration: 2000,
						icon: 'none'
					});
					return false;
				} else {
					let flag = false;
					this.perList.map((i, index) => {
						if (!i.ordertel || !i.ordername || !i.personid) {
							uni.showToast({
								title: '游客信息填写不正确！',
								duration: 2000,
								icon: 'none'
							});
							flag = true;
							return false;
						}
						if (!this.isPhone(i.ordertel)) {
							uni.showToast({
								title: '手机号格式不正确！',
								duration: 2000,
								icon: 'none'
							});
							flag = true;
							return false;
						}
						if (i.personid && !this.isCardNo(i.personid)) {
							uni.showToast({
								title: '身份证格式不正确！',
								duration: 2000,
								icon: 'none'
							});
							flag = true;
							return false;
						}
						if(index == 0) {
							name = i.ordername;
							ordertel = i.ordertel;
							personid = i.personid;
						} else {
							name += ',' +  i.ordername;
							ordertel += ',' +  i.ordertel;
							personid += ',' +  i.personid;
						}

					})
					if (flag) {
						return
					}
				}
				

				let data = {
					tid: this.prodMsg.uuid,
					playtime: this.timeList[this.timeAcIndex].date, // 什么时间
					tnum: this.value,
					// ordertel: this.perList[0].ordertel,
					// ordername: this.perList[0].ordername,
					// personid: this.perList[0].personid,
					// ordertel:  ordertel,
					ordertel:  this.perList[0].ordertel,
					ordername: name,
					personid: personid,
					m: this.prodMsg.uuaid, //景区名
					paymode: 0, // 是什么？
					// personid: '210323200001060213',
					// tprice: parseFloat(this.timeList[this.timeAcIndex].buyPrice * this.value), // 怎么传
					tprice: parseFloat(this.timeList[this.timeAcIndex].buyPrice)
					// tprice: 0.01,
				}
				this.$httpFormData.post(
					this.$myApi.orderPrice,
					data, {
						header: {
							'Content-Type': 'application/x-www-form-urlencoded;charset=utf8',
							"Authorization": uni.getStorageSync('token') || 1,
							Clientid: uni.getStorageSync('clientID') || 1
						},
					}
				).then(res => {
					// // console.log(res, '预判下单返回的结果')
					if (res.data.code == 100) {
						// // console.log('预判下单成功，调起微信支付', res);
						this.payWx()
					} else {
						// // console.log('走了这里吗？')
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}

				}).catch(err => {
					uni.showToast({
						title: err.msg,
						duration: 2000,
						icon: 'none'
					});
				})
			},
			// 支付接口
			// 12位随机数
			generateRefundNumber() {
				const datePrefix = '';
				// 生成12位随机数  
				const randomSuffix = Math.floor(100000000000 + Math.random() * 900000000000)
			.toString(); // 生成12位随机数，范围从100000000000到999999999999  
				// 拼接前缀和后缀，形成退款流水号  
				const refundNumber = ` ${randomSuffix}`;
				return refundNumber;
			},
			payWx() {
				this.orderId = this.generateRefundNumber()
				// 支付信息
				let data = {
					openId: uni.getStorageSync('openId').openid,
					// amount: parseFloat(this.timeList[this.timeAcIndex].retailPrice * this.value),
					amount: parseFloat(this.allMoney - this.userJF).toFixed(2) * 100,
					description: this.value + '张' + this.prodMsg.uutitle, // 门票名称
					attach: {
						"userName": this.perList[0].ordername,
						"idCard": this.perList[0].personid,
						"scenicSpotsId": this.prodMsg.number,
						"orderId": this.orderId,
					}
				}

				if (this.allMoney - this.userJF == 0) {
					// console.log(111111111111)
					let _this = this;
					uni.showModal({
						title: '提示',
						content: '你确定要使用积分下单吗？',
						success: function(res) {
							if (res.confirm) {
								_this.submitOrder();
							} else if (res.cancel) {
								// console.log('取消');
							}
						}
					});
					return;
				}
				// console.log(data, '预判下单走的接口内容')
				this.$http({
					url: this.$myApi.creatOrderJSAPI,
					method: 'GET',
					hideLoading: true,
					data: data,
					success: res => {
						if (res.code == 200) {
							// 调取真正的微信支付
							// res.data
							let orderInfo = res.data;
							uni.requestPayment({
								provider: 'wxpay',
								appId: orderInfo.appId,
								timeStamp: orderInfo.timeStamp,
								nonceStr: orderInfo.nonceStr,
								package: orderInfo.package,
								signType: 'MD5',
								paySign: orderInfo.paySign,
								success: res => {
									// console.log('success:-------', res);
									// 先去提交订单
									this.submitOrder(orderInfo);
								},
								fail: err => {
									this.$refs.uToast.show({
										title: '支付失败',
										type: 'error'
									})
									// console.log('fail:---------', err);
								}
							});
						}
					},
					fail: err => {
						// console.log(err)
					}
				});
			},
			generateOrderNumber() {
				// 生成前缀部分  
				const prefix = Math.floor(Math.random() * 9000) + 1000;
				// 生成后缀部分  
				const suffix = Math.floor(Math.random() * 10000) + 1000;
				// 拼接成16位订单号  
				const orderNumber = prefix + String(suffix).padStart(6, '0');
				return orderNumber;
			},
			// 提交订单
			submitOrder() {
				console.log('到这里了')
				let ordertel = '';
				let ordername = '';
				let personid = '';

				this.perList.map((i, index) => {
					if(index == 0) {
						ordername = i.ordername;
						ordertel = i.ordertel;
						personid = i.personid;
					} else {
						ordername += ',' +  i.ordername;
						ordertel += ',' +  i.ordertel;
						personid += ',' +  i.personid;
					}
				})


				let payType = 0;
				if (this.userJF > 0) {
					payType = 2
				}
				if (this.allMoney - this.userJF == 0) {
					payType = 1;
				}
				let data = {
					id: this.orderId,
					lid: this.prodMsg.uulid,
					tid: this.prodMsg.uuid,
					remotenum: this.orderId,
					tprice: this.zfMoney * 100,
					tnum: this.value,
					playtime: this.timeList[this.timeAcIndex].date,
					// ordertel: this.perList[0].ordertel,
					// contactTEL: this.perList[0].ordertel,
					// ordername: this.perList[0].ordername,
					// personID: this.perList[0].personid,
					// ordertel: ordertel.slice(0, -1),
					// contactTEL: ordertel.slice(0, -1),
					// ordername: ordername.slice(0, -1),
					// // personID:  '210323200001060213',
					// personID: personID.slice(0, -1),
					
					ordertel:this.perList[0].ordertel,
					contactTEL: ordertel,
					ordername: ordername,
					personID: personid,
					smsSend: 1,
					paymode: 0,
					orderMode: 0,
					assembly: '',
					series: '',
					concatID: '',
					pCode: '',
					m: this.prodMsg.uuaid,
					memo: '',
					callbackUrl: '',
					userId: uni.getStorageSync('openId').userId,
					orderPoints: this.userJF, // 订单积分元
					totalAmount: parseFloat(this.timeList[this.timeAcIndex].retailPrice * this.value), // 订单总价格 分
					promoAmount: 0, // 优惠券价格
					pointsFlag: this.userJF > 0 ? 1 : 0, // 积分使用标志 this.userJf，
					promoFlag: 0, //优惠券使用标志  0否1是，
					payType: payType // 支付方式  0现金 1积分 2现金+积分 3现金优惠券 4现金积分优惠券 5积分优惠券
				}
				console.log(data, 333333333, '提交订单了')

				// 提交订单
				// submitOrder
				this.$httpFormData.post(
					this.$myApi.submitOrder,
					data, {
						header: {
							'Content-Type': 'application/x-www-form-urlencoded;charset=utf8',
							"Authorization": uni.getStorageSync('token') || 1,
							Clientid: uni.getStorageSync('clientID') || 1
						},
					}
				).then(res => {
					// console.log('提交订单的信息', res);
					if (res.data.code == 200) {
						uni.redirectTo({
							url: '/pages/PaySuccess/index?price=' + parseFloat(parseFloat(this.timeList[
								this.timeAcIndex].retailPrice * this.value) / 100).toFixed(2)
						});
					} else {
						uni.showToast({
							title: res.data.msg,
							duration: 2000,
							icon: 'none'
						});
					}


				}).catch(err => {
					uni.showToast({
						title: err.msg,
						duration: 2000,
						icon: 'none'
					});
				})
			},
			open() {
				// // console.log('open');
			},
			close() {
				this.show = false
				// // console.log('close');
			},
			// 使用优惠券
			userCoupon() {
				// uni.navigateTo({
				// 	url: '/pages/coupon/index'
				// })
			},
			// 小程序登录
			login(e) {
				if (!this.init) {
					this.$refs.uToast.show({
						title: '请勾选相关协议',
						type: 'error',
					})
					return
				}
				// console.log(e)
				const _this = this
				if (e.detail.userInfo) {
					uni.login({
						provider: 'weixin',
						success: loginRes => {
							// console.log('userInfo------', e.detail.userInfo)
							this.userInfo = e.detail.userInfo
							// console.log('login--------', loginRes);
							this._login(loginRes.code)
						}
					});
				} else {
					this.$refs.uTips.show({
						title: '未授权，登录失败',
						type: 'error',
						duration: '2300'
					})
				}

			},
			_login(e) {
				this.loading = true
				this.$http({
					url: this.$api.WxLogin,
					method: 'GET',
					hideLoading: true,
					data: {
						code: e,
						InvitedCode: this.InvitedCode,
					},
					success: res => {
						// console.log('登录结果----------', res)

						this.loginData = res.data
						if (!res.data.phone) {
							this.show = true
						} else {
							this._userinfo(res.data)
						}
						uni.setStorage({
							key: 'openId',
							data: res.data,
						});
					},
					complete: e => {
						this.loading = false
					}
				})
			},
			// 获取用户手机号
			getPhone(e, index) {
				if (uni.getStorageSync('openId').phonenumber) {
					this.perList[index].ordertel = uni.getStorageSync('openId').phonenumber;
					return;
				}
				let data = {
					"code": e.detail.code
				}
				this.$httpFormData.post(
					this.$myApi.getPhone,
					data, {
						header: {
							'Content-Type': 'application/x-www-form-urlencoded;charset=utf8',
							"Authorization": uni.getStorageSync('token') || 1,
							Clientid: uni.getStorageSync('clientID') || 1
						}
					}
				).then(res => {
					// console.log('获取到的手机号信息', res);
					this.perList[index].ordertel = res.data;
					// console.log(this.perList)
				}).catch(err => {
					uni.showToast({
						title: err.msg,
						duration: 2000,
						icon: 'none'
					});
				})
			},
			// 身份证信息校验
			isCardNo(card) {
				// 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X  
				var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				if (reg.test(card) === false) {
					// this.$msg("身份证输入不合法");
					return false;
				} else {
					return true;
				}
			},
			// 校验方法
			// cardno(newVal, oldVal) {
			// 	if (!this.isCardNo(this.cardno)) {
			// 		this.disBtn = true
			// 	} else {
			// 		this.disBtn = false
			// 	}
			// },
			isPhone(phone) {
				var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
				if (!myreg.test(phone)) {
					return false;
				} else {
					return true;
				}
			},
			addPerInfos() {
				let id = [];
				this.perList.map(i => {
					id += ',' + i.id
				})
				uni.navigateTo({
					url: '/pages/infoMsg/index?type=1&id=' + id
				})
			},
			addPerInfo() {
				this.perList.push({
					ordername: '',
					ordertel: '',
					idcardnumber: '',
				})
				// 滚动条到最底部
				// 设置成同一值后不改变
				var random_num = Math.random() * 99.9999 + 1.00000
				this.scrollToTop = 999999 + random_num;
				// // console.log(this.scrollToTop, 322222222)
			},
			// 刪除
			deletePerInfo(index) {
				// // console.log(index, 11111111)
				this.perList.splice(index, 1)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.add-info {

		// margin: 0 auto;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #4C4C4C;
		// margin-top: 23rpx;
		// width: 264rpx;
		padding: 0rpx 32rpx;
		height: 56rpx;
		background-color: #DFDFDF;
		// border: 1px solid #0B96FF;
		border-radius: 24rpx !important;
		height: 56rpx !important;
		line-height: 56rpx !important;
		text-align: center;
		border-radius: 10rpx;
		// color: #0B96FF;

		image {
			margin-right: 24rpx;
			position: relative;
			top: 8rpx;
			// display: none;
		}
	}

	.my-title {
		height: 56rpx;
		line-height: 56rpx;
	}

	.per-box {
		.per-info-box {
			position: relative;
			padding-bottom: 76rpx;

			.names,
			.phone,
			.idcardnumber {
				display: flex;
				flex-direction: row;
				// justify-content: space-between;
				height: 81rpx;
				line-height: 81rpx;
				border-bottom: 1rpx solid #C7C7C7;

				.label {
					width: 94rpx;
					height: 40rpx;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					color: #787878;
					text-align-last: justify;
					text-align: justify;

				}

				.unt {
					color: #FF0000;
					position: relative;
					left: 0rpx;
					width: 6rpx;
				}

				.myinput {
					margin-top: 14rpx;
					width: 480rpx;
					margin-left: 56rpx;
				}

				&.phone {
					.myinput {
						width: 280rpx;
					}


				}

			}
		}


		.delete-info {
			position: absolute;
			right: 0rpx;
			background-color: transparent;
		}
	}

	::v-deep {
		.u-number-input {
			background-color: #fff !important;
			margin: 0rpx 80rpx !important;
		}

		.u-icon-plus,
		.u-icon-minus {
			width: 76rpx !important;
			height: 76rpx !important;
			border-radius: 50% !important;
		}
	}

	.category-first {
		height: calc(100vh - 360rpx);
	}

	.content {
		background-color: #EFEFEF;
		overflow: auto;
		height: calc(100vh - 360rpx);
		// padding-bottom: 40rpx;
	}

	.my-conts {
		width: 690rpx;
		// height: 100%;
		// min-height: 100vh;
		// height: 100%;
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		padding: 22rpx 27rpx 36rpx 30rpx;
		margin: 0 auto;
		// 


		.number-box {
			margin-top: 40rpx;
			padding-bottom: 76rpx;
			border-bottom: 1rpx solid #707070;
			text-align: center;
		}

		.name2 {
			border-bottom: 1rpx solid #c7c7c7;
			padding-bottom: 22rpx;
			margin-bottom: 0rpx !important;
		}

		.name1 {
			margin-top: 22rpx;
		}

		.quan-box {
			padding-bottom: 33rpx;
			border-bottom: 1rpx solid #707070;
			margin-top: 32rpx;
		}

		.quan {
			font-size: 26rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #232323;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			margin-top: 18rpx;
			height: 36rpx;
			line-height: 36rpx;

			// padding-bottom: 18rpx;
			.unit {
				color: #FF3400;

				.font {
					color: #232323;
				}
			}
		}

		.cs-time {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			flex-wrap: wrap;
			padding-bottom: 23rpx;
			border-bottom: 1rpx solid #707070;
			width: 100%;

			.cs-item {
				width: 162rpx;
				height: 77rpx;
				background: #FFFFFF;
				border-radius: 10rpx;
				opacity: 1;
				border: 1rpx solid #707070;
				font-size: 20rpx;
				line-height: 77rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #1C1C1C;
				text-align: center;
				margin-bottom: 33rpx;

				&.cs-last-item {
					width: 68rpx;
					line-height: 30rpx;
					padding-top: 12rpx;
				}

				&.acIndex {
					background: #B5FFD0;
					opacity: 1;
					border: 1rpx solid #0DBA5A;
				}

			}

			.my-item:nth-child(n + 5) {
				display: none;
			}
		}

		.name {
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #1C1C1C;
			margin-bottom: 22rpx;
		}
	}

	.pay-box {
		width: 750rpx;
		text-align: center;
		position: fixed;
		background-color: #fff;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		bottom: 0rpx;
		z-index: 9;

		// height: 330rpx;
		.btm {
			margin: 0 auto;
			margin-bottom: 41rpx;
			width: 576rpx;
			height: 82rpx;
			line-height: 82rpx;
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			text-align: center;
			background-color: #0DBA5A;
		}

		.title {
			height: 42rpx;
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #1C1C1C;
			margin-top: 68rpx;
			margin-bottom: 29rpx;
		}

		.money {
			font-size: 50rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			color: #FF6F00;
			height: 70rpx;
			margin-bottom: 138rpx;
			line-height: 70rpx;

			.unit {
				font-size: 30rpx;
				margin-top: 5rpx;
				margin-right: 8rpx;

			}
		}
	}
</style>
<style>
	page {
		background: #EFEFEF;
		overflow: hidden;
	}
</style>

<style lang="scss">
	// 数字按钮的样式
	.minus {
		width: 22px;
		height: 22px;
		border-width: 1px;
		border-color: #E6E6E6;
		border-style: solid;
		border-top-left-radius: 100px;
		border-top-right-radius: 100px;
		border-bottom-left-radius: 100px;
		border-bottom-right-radius: 100px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.input {
		padding: 0 10px;
	}

	.plus {
		width: 22px;
		height: 22px;
		background-color: #FF0000;
		border-radius: 50%;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
	}

	.bottom {
		position: fixed;
		bottom: 0rpx;
		width: 750rpx;
		// background-color: #0DBA5A;
		display: flex;
		flex-direction: row;
		height: 96rpx;

		.left {
			width: 106rpx;
			height: 96rpx;
			background-color: #676767;
			text-align: center;
			color: #fff;
			position: relative;

			.img1 {
				width: 50rpx;
				height: 50rpx;
				margin-top: 10rpx;
			}

			view {
				height: 30rpx;
				line-height: 30rpx;
				font-size: 22rpx;
				position: relative;
				top: -8rpx;
			}
		}

		.right {
			text-align: center;
			width: 644rpx;
			background-color: #0DBA5A;
			color: #fff;
			font-size: 30rpx;
			line-height: 96rpx;
		}
	}


	.phone-btn {
		&.my-phone-btn {
			width: 202rpx !important;
			height: 50rpx !important;
			background: #FFFFFF;
			border-radius: 24rpx !important;
			opacity: 1;
			border: 1px solid #0091FF !important;
			font-size: 24rpx !important;
			font-family: PingFang SC, PingFang SC !important;
			font-weight: 500;
			color: #0091FF !important;
			line-height: 50rpx !important;
			text-align: center !important;
			margin-top: 18rpx !important;
			background-color: #fff !important;

			&:active,
			&:click {
				background-color: #fff !important;
				opacity: 0.7 !important;
			}
		}

		::v-deep {
			.u-btn--primary {
				width: 202rpx !important;
				height: 50rpx !important;
				background: #FFFFFF;
				border-radius: 20rpx !important;
				opacity: 1;
				border: 1px solid #0091FF !important;
				font-size: 24rpx !important;
				font-family: PingFang SC, PingFang SC !important;
				font-weight: 500;
				color: #0091FF !important;
				line-height: 50rpx !important;
				text-align: center !important;
				margin-top: 18rpx !important;
				background-color: #fff !important;

				&:active,
				&:click {
					background-color: #fff !important;
					opacity: 0.7 !important;
				}
			}
		}
	}

	.time-all {
		font-size: 28rpx;
		padding-bottom: 32rpx;

		.yue {
			font-size: 28rpx;
			width: 100%;
			text-align: center;
			line-height: 36rpx;
			height: 36rpx;
			margin-bottom: 12rpx;
			margin-top: 24rpx;
		}

		.title {
			position: relative;
			text-align: center;
			line-height: 48rpx;
			margin-top: 12rpx;
			margin-bottom: 12rpx;
			font-size: 32rpx;

			.close {
				position: absolute;
				right: 12rpx;
				top: -2rpx;
				cursor: pointer;
				user-select: none;
				font-size: 44rpx;
			}
		}

		.day-box {
			display: flex;
			flex-direction: row;
			// justify-content: space-around;
			flex-wrap: wrap;

			.my-day {
				width: 14.28%;
				text-align: center;

				.day {
					font-size: 32rpx;
					margin-top: 12rpx;
					line-height: 40rpx;
					cursor: pointer;
					user-select: none;
				}

				.money {
					font-size: 24rpx;
					color: #676767;
				}

				.ac-day {
					color: #F8C23D;

					.money {
						color: #F8C23D;
					}
				}
			}
		}

		.sunday {
			display: flex;
			flex-direction: row;
			// justify-content: space-between;
			padding: 0rpx 12rpx;
			border-bottom: 1rpx solid #ccc;
			padding-bottom: 16rpx;
			margin-bottom: 24rpx;

			view {
				width: 14.28%;
				text-align: center;

				&:first-child,
				&:last-child {
					color: #F8C23D;
				}
			}
		}

	}

	.customer-service {
		background-color: red;
		color: #fff;
		width: 100%;
		font-size: 24rpx;
		padding: 0px !important;
		display: inline-block;
		position: absolute;
		width: 100%;
		background: salmon;
		width: 106rpx;
		height: 96rpx;
		left: 0rpx;
		top: 0rpx;
		opacity: 0;

	}
</style>